package MRdemo;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.output.MultipleOutputs;

import java.io.IOException;

public class ReducerFile extends Reducer<ReWriteKey,Text, IntWritable,Text> {
    private int i=1;
    @Override
    protected void setup(Context context) throws IOException, InterruptedException {

    }

    @Override
    protected void reduce(ReWriteKey rwk, Iterable<Text> values, Context context) throws IOException, InterruptedException {

        for (Text text:values){
            String line = text.toString();
            // 输出结果
            context.write(new IntWritable(i++), new Text(line));
        }
    }

    @Override
    protected void cleanup(Context context) throws IOException, InterruptedException {

    }
}
